<?php
session_start();
include("../include/config.inc.php");
include("../include/version.inc.php");
include("../include/tables.inc.php");
include("../include/funktion.inc.php");
include("../include/rights.inc.php");
include("../include/xtea.inc.php");


if(!isset($_SESSION['userid']))
   weiterleitung("index.php");

$rights = $_SESSION['ses_rights'];
$menu = menu($rights);

if(!check($_SERVER['PHP_SELF'],$rights))
  weiterleitung("uebersicht.php");

$was = $_GET['was'];
$fehler = "";

if($was == "save")
   {
   $name = $_POST['name'];
   $email = $_POST['email'];
   $email_antwort = $_POST['email_antwort'];
   $send_step = $_POST['send_step'];
   $use_smtp = $_POST['use_smtp'];
   $smtp_username = $_POST['smtp_username'];
   $smtp_password = $_POST['smtp_password'];
   $smtp_host = $_POST['smtp_host'];
   $archiv = $_POST['archiv'];
   $refresh = (isset($_POST['HTTP_REFERER'])) ? "HTTP_REFERER|".$_POST['refresh'] : $_POST['refresh'];


   mysql_query("UPDATE `$configdb` SET `wert` = '$name' WHERE `feld` = 'name'");
   mysql_query("UPDATE `$configdb` SET `wert` = '$email' WHERE `feld` = 'email'");
   mysql_query("UPDATE `$configdb` SET `wert` = '$email_antwort' WHERE `feld` = 'email_antwort'");
   mysql_query("UPDATE `$configdb` SET `wert` = '$send_step' WHERE `feld` = 'send_step'");
   mysql_query("UPDATE `$configdb` SET `wert` = '$use_smtp' WHERE `feld` = 'use_smtp'");
   mysql_query("UPDATE `$configdb` SET `wert` = '$smtp_username' WHERE `feld` = 'smtp_username'");
   mysql_query("UPDATE `$configdb` SET `wert` = '$smtp_host' WHERE `feld` = 'smtp_host'");
   mysql_query("UPDATE `$configdb` SET `wert` = '$archiv' WHERE `feld` = 'archiv'");
   mysql_query("UPDATE `$configdb` SET `wert` = '$refresh' WHERE `feld` = 'refresh'");

   if(trim($smtp_password) != "")
      {
      $smtp_password = xtea_encrypt($smtp_password,$rand_array);
      mysql_query("UPDATE `$configdb` SET `wert` = '$smtp_password' WHERE `feld` = 'smtp_password'");
      }

   $config = config();
   }

$url = $config['refresh'];

if($url === "HTTP_REFERER" OR (strstr($url,"|") AND substr($url,0,strpos($url,"|")) === "HTTP_REFERER"))
   $url = substr(strchr($url,"|"),1);
?>


<html>
<head>
<title>Clanletter - Admin Bereich</title>
<meta name="author" content="Andavos">
<style type="text/css">
<!--
a:hover { text-decoration:none; }

BODY {

     SCROLLBAR-FACE-COLOR: #4F5271;
     SCROLLBAR-HIGHLIGHT-COLOR: #243D62;
    SCROLLBAR-SHADOW-COLOR: rgb(32,32,32);
    SCROLLBAR-ARROW-COLOR: #ffffff;

}

.anhang {
 font-size: 14px;
 color: #000000;
 background-color: #899FBF;

 border-color: #000000;
 border-top-width :1pt;
 border-right-width : 1px;
 border-bottom-width : 1px;
 border-left-width : 1px;
}

-->
</style>


</head>
<body text="#000000" bgcolor="#D0D0D0" link="#000060" alink="#000060" vlink="#000060">


<table cellpadding="5" cellspacing="2"  bgcolor="black" align="center" width="85%">
<tr>
 <td width="205" valign="top" bgcolor="#899FBF"><a target="_blank" href="http://www.php-einfach.de"><img src="php-einfach.jpg" width="199" height="66" border="0" alt="PHP-Einfach.de"></a> <br>


 <?php echo $menu; ?>


<font size="-1"> <a target="_blank" href="http://www.php-einfach.de">&copy; PHP-Einfach.de Clanletter 2.0</a><br>
 </td>
  <td valign="top" bgcolor="#9BAAC1">
<div align="center"><h2>Einstellungen</h2></div>

<center><font color="#BD0000"><b><?php echo $fehler; ?></b></font></center>


<form action="?was=save" method="post" target="">
<table bgcolor="#000000" cellpadding="5" cellspacing="1" align="center" width="75%">
<tr bgcolor="#314477">
 <th colspan="2"><font color="#ffffff"><b>Absender</b></font></td>
</tr>

<tr bgcolor="#FFFFFF">
 <td width="125"><b>Name:</b></td>
 <td><input type="Text" name="name" value="<?php echo $config['name']; ?>" size="35" maxlength="50"></td>
</tr>

<tr bgcolor="#FFFFFF">
 <td width="125"><b>Email:</b></td>
 <td><input type="Text" name="email" value="<?php echo $config['email']; ?>" size="35" maxlength="50"></td>
</tr>

<tr bgcolor="#FFFFFF">
 <td width="125"><b>Antwortadresse:</b></td>
 <td><input type="Text" name="email_antwort" value="<?php echo $config['email_antwort']; ?>" size="35" maxlength="50"></td>
</tr>

<tr bgcolor="#314477">
 <th colspan="2"><font color="#ffffff"><b>SMTP</b></font></td>
</tr>

<tr bgcolor="#FFFFFF">
 <td width="125"><b>Externen SMTP-Server verwenden:</b></td>
 <td>
 <input type="Radio" name="use_smtp" value="0" id="no" <?php ($config['use_smtp'] == "1") ? "" : print("checked"); ?>><label for="no"> Nein </label> <br>
 <input type="Radio" name="use_smtp" value="1" id="ja" <?php ($config['use_smtp'] == "1") ? print("checked") : ""; ?>><label for="ja"> Ja </label>
 </td>
</tr>

<tr bgcolor="#FFFFFF">
 <td width="125"><b>SMTP-Server:</b></td>
 <td><input type="Text" name="smtp_host" value="<?php echo $config['smtp_host']; ?>" size="35" maxlength="50"></td>
</tr>

<tr bgcolor="#FFFFFF">
 <td width="125"><b>SMTP-Username:</b></td>
 <td><input type="Text" name="smtp_username" value="<?php echo $config['smtp_username']; ?>" size="35" maxlength="50"></td>
</tr>

<tr bgcolor="#FFFFFF">
 <td width="125"><b>SMTP-Passwort:</b></td>
 <td><input type="Password" name="smtp_password" value="    " size="35" maxlength="50"></td>
</tr>

<tr bgcolor="#314477">
 <th colspan="2"><font color="#ffffff"><b>Sonstiges</b></font></td>
</tr>

<tr bgcolor="#FFFFFF">
 <td width="125"><b>Archiv:</b></td>
 <td><input type="Radio" name="archiv" value="0" id="archiv_no" <?php ($config['archiv'] == "1") ? "" : print("checked"); ?>><label for="archiv_no"> Nein </label> <br>
 <input type="Radio" name="archiv" value="1" id="archiv_ja" <?php ($config['archiv'] == "1") ? print("checked") : ""; ?>><label for="archiv_ja"> Ja </label>
 </td>
</tr>

<tr bgcolor="#FFFFFF">
 <td width="125"><b>Weiterleitungs Adresse:</b></td>
 <td><input type="Text" name="refresh" value="<?php echo $url; ?>" size="35" maxlength="150"> oder <input type="Checkbox" name="HTTP_REFERER" value="1" id="HTTP_REFERER" <?php echo ($config['refresh'] === "HTTP_REFERER" OR (strstr($config['refresh'],"|") AND substr($config['refresh'],0,strpos($config['refresh'],"|")) === "HTTP_REFERER")) ? "checked" : "" ?>><label for="HTTP_REFERER"> Herkunfsseite</label> </td>
</tr>

<tr bgcolor="#FFFFFF">
 <td width="125"><b>Emails pro Schritt senden:</b></td>
 <td><input type="Text" name="send_step" value="<?php echo $config['send_step']; ?>" size="2" maxlength="3"> <small>(Kleinere Zahl w&auml;hlen, falls Server beim Senden abbricht)</small></td>
</tr>
</table>


<br>
<center><input type="Submit" name="" value="Speichern"></center>
</form>

<table bgcolor="#000000" cellpadding="5" cellspacing="1" align="center" width="75%">

<tr bgcolor="#FFFFFF">
 <td>
Falls dein Newsletter bei manchen Personen nicht ankommt, solltest du als Absenderadresse die des Servers angeben: <b><?php echo $_SERVER['SERVER_ADMIN']; ?> </b><br>
und als Antwortadresse deine echte Adresse.<br>
Oft hilft es auch den Newsletter &uuml;ber einen SMTP-Server versenden.<br><br>

<a target="_blank" href="http://www.php-einfach.de/downloads_clanletter_faq.php#server_mail">Weitere Infos</a>

</td>
</tr>
</table>



  </td>
</tr>
</table>

</body>
</html>